]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
location: React to changes in available accuracy level
authorZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Sat, 15 Feb 2014 16:28:58 +0000 (16:28 +0000)
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Sat, 15 Feb 2014 17:41:26 +0000 (17:41 +0000)
GPS could be plugged in and out, network can go up and down and
therefore available accuracy level can also change.

https://bugzilla.gnome.org/show_bug.cgi?id=723684

js/ui/status/location.js

index 7f68b366bdfc594339d88b7502ee865777b62c9d..fb78b152cf56cefc5f752e64e40114a9bb08fe71 100644 (file)
@@ -41,7 +41,6 @@ const Indicator = new Lang.Class({
 
         this._indicator = this._addIndicator();
         this._indicator.icon_name = 'find-location-symbolic';
-        this._syncIndicator();
 
         this._item = new PopupMenu.PopupSubMenuMenuItem(_("Location"), true);
         this._item.icon.icon_name = 'find-location-symbolic';
@@ -122,14 +121,9 @@ const Indicator = new Lang.Class({
         }
 
         this._proxy = proxy;
-        this._proxy.connect('g-properties-changed', Lang.bind(this, this._syncIndicator));
-
-        if (!this._availableAccuracyLevel) {
-            this._availableAccuracyLevel = this._proxy.AvailableAccuracyLevel;
-            this._maxAccuracyLevel = this._availableAccuracyLevel;
-            this._updateMenuVisibility();
-        }
+        this._proxy.connect('g-properties-changed', Lang.bind(this, this._onGeocluePropsChanged));
 
+        this._updateMenuVisibility();
         this._syncIndicator();
 
         this._proxy.AddAgentRemote('gnome-shell', Lang.bind(this, this._onAgentRegistered));
@@ -187,7 +181,20 @@ const Indicator = new Lang.Class({
     },
 
     _updateMenuVisibility: function() {
+        this._availableAccuracyLevel = this._proxy.AvailableAccuracyLevel;
+        if (!this._maxAccuracyLevelInitialized) {
+            this._maxAccuracyLevel = this._availableAccuracyLevel;
+            this._maxAccuracyLevelInitialized = true;
+        }
         this.menu.actor.visible = (this._availableAccuracyLevel != 0);
+    },
+
+    _onGeocluePropsChanged: function(proxy, properties) {
+        let unpacked = properties.deep_unpack();
+        if ("InUse" in unpacked)
+            this._syncIndicator();
+        if ("AvailableAccuracyLevel" in unpacked)
+            this._updateMenuVisibility();
     }
 });